/**
 * Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
 * Copyright (c) <spug.dev@gmail.com>
 * Released under the AGPL-3.0 License.
 */
import { observable } from "mobx";
import http from 'libs/http';
import moment from "moment";

class Store {
  @observable records = [];
  @observable record = {};
  @observable types = [];
  @observable isFetching = false;
  @observable formVisible = false;

  @observable f_name;
  @observable f_type;
  @observable f_status;
  @observable templateStep = []
  @observable templateStep_init = [
        {
            id: 0,
            title: '提交阶段',
            auditor: '提交人',
            type: 0,  // 0 audit 1 executor
        }
    ]

  fetchRecords = () => {
    this.isFetching = true;
    http.get('/api/workorder/template/')
      .then(res => {
        this.records = res
      })
      .finally(() => this.isFetching = false)
  };

  showForm = (info = {}) => {
    this.formVisible = true;
    this.record = info
    this.templateStep = info.flow ? eval(info.flow) : this.templateStep_init
  }
}

export default new Store()
